const http = require("http");

const renderStatus = require("./module/renderStatus.js");
const renderHTML = require("./module/renderHTML.js");

http
  .createServer((req, res) => {
    //req:接收浏览器传的参数
    //res:返回渲染的内容
    if (req.url === "/favicon.ico") {
      //todo:读取本地图标
      return;
    }
    res.writeHead(renderStatus.renderStatus(req.url), {
      "Content-Type": "text/html;charset=utf-8",
    });

    res.write(renderHTML.renderHTML(req.url));
    res.end();
  })
  .listen(5200, () => {
    console.log("server start");
  });
